 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>API functions  - Sigma Ajax data grid control sample</title>
<meta http-equiv="Content-Language" content="en-us" /> 
<meta name="keywords" content="dhtml grid, AJAX grid, API functions " >
<meta name="description" content="Sigma grid API functions" >
	



<link rel="stylesheet" type="text/css" media="all" href="../grid/calendar/calendar-blue.css"  />
<script type="text/javascript" src="../grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../grid/calendar/calendar-setup.js"></script>

<link rel="stylesheet" type="text/css" href="../grid/gt_grid.css" />
<link rel="stylesheet" type="text/css" href="../grid/skin/vista/skinstyle.css" />
<script type="text/javascript" src="../demos/data/cell_image.js"></script>
<script type="text/javascript" src="../grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../grid/gt_grid_all.js"></script>
<script type="text/javascript" src="../grid/flashchart/fusioncharts/FusionCharts.js"></script>

<!-- case case lib-->
<link rel="stylesheet" type="text/css" media="all" href="framework/qunit.css"  />
<script type="text/javascript" src="framework/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="framework/qunit.js"></script>
    
    
<script type="text/javascript" >

var grid_demo_id = "myGrid1" ;


var dsOption= {

	fields :[
		{name : 'no'  },
		{name : 'country'  },
		{name : 'customer'  },
		{name : 'employee'  },
		{name : 'bill2005' ,type: 'float' },
		{name : 'bill2006' ,type: 'float' },
		{name : 'bill2007' ,type: 'float' },
		{name : 'bill2008' ,type: 'float' },
		{name : 'orderDate' ,type:'date'  }
		
	],
	recordType : 'array',
	data : __TEST_DATA__
}

function my_renderer(value ,record,columnObj,grid,colNo,rowNo){
		var no= record[columnObj.fieldIndex];
		return "<img src=\"./images/flag_" + no.toLowerCase() + ".gif\">";
}

var colsOption = [
     {id: 'no' , header: "Order No" , width :60  },
     {id: 'employee' , header: "Employee" , width :80  },
	   {id: 'country' , header: "Country" , width :40, renderer:my_renderer},
	   {id: 'customer' , header: "Customer" , width :80  },
	   {id: 'bill2005' , header: "2005" , width :60},
	   {id: 'bill2006' , header: "2006" , width :60},
	   {id: 'bill2007' , header: "2007" , width :60},
	   {id: 'bill2008' , header: "2008" , width :60},
	   {id: 'orderDate' , header: "Delivery Date" , width :100}
       
];
 

var gridOption={
  id : grid_demo_id,
	width: "700",  //"100%", // 700,
	height: "200",  //"100%", // 330,
	
	container : 'gridbox', 
	replaceContainer : true, 
	
	dataset : dsOption ,
	columns : colsOption,
	pageSize : 10 ,
	toolbarContent : 'nav'
	
};




var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad( Sigma.Grid.render(mygrid));

//----------------------test functions-----------------------------
$(document).ready(function() {

test("Sigma Grid API Test", function() {
  stop();  
    
  setTimeout(function() {
      //add row test
      recSet = ["050-9","FR","Evan","Chris",66,76,43,63,"2008-04-04"];
      mygrid.addRow(recSet); 
      recs = mygrid.getInsertedRecords();
      ok(recs.length===1, "1 records inserted" );
      equal(recs[0], recSet, "insert rec equals to inserted");
      //deleted row
      mygrid.deleteRow(mygrid.getRowByRecord(recs[0]));
      recs = mygrid.getInsertedRecords();
      ok(recs.length===0, "inserted row deleted" );
      mygrid.syncScroll(0,0);
      
      
      //delete row test
      row = mygrid.getRow(0);
      recDeleted = mygrid.getRecord(0);
      mygrid.deleteRow(row);
      recs = mygrid.getDeletedRecords();
      ok(recs.length===1, "1 records deleted" );
      equal(recs[0], recDeleted, "deleted rec equals to deleted"); 
      mygrid.deleteRow(row);
      
      
      //selectRow  
      row = mygrid.getRow(0);
      mygrid.selectRow(row, false);
      row = mygrid.getRow(5);
      mygrid.selectRow(row, true);
      recs = mygrid.getSelectedRecords();
      ok(recs.length===1, "1 records selected" );
      expected = ["020-5","US","Leopold","Glendon",90,77,98,36,"2008-08-07"];
      equal(recs[0], expected, "selected rec equals to inserted");
      
      //clean content 
      //recs = mygrid.getAllCon
      mygrid.cleanContent();
      
      
      start();
  }, 3000);   
});



  
});


//////////////////////////////////////////////////////////






</script>
</head>
<body>

<div id="page-container">
  <div id="main-nav">
            <div id="logo" style="margin: 10px">
                                        <a href="http://www.sigmawidgets.com/">
                                            <img border="0"  src="images/logo.gif"/></a></div>
                                    <div id="menu">
                                        <div class="menuLinkHome">
                                            <a href="http://www.sigmawidgets.com/">Home</a></div>
                                        <div class="menuLink" id="menu1">
                                            <a href="http://www.sigmawidgets.com/products/sigma_grid2/">Products </a>
                                        </div>
                                        <div class="menuLink" id="menu2">
                                            <a href="http://www.sigmawidgets.com/company/offshore.html">Company &amp;Services</a>
                                        </div>
                                        <div class="menuLink" id="menu3" >
                                            <a href="http://www.sigmawidgets.com/products/sigma_grid2/demos/"><font color="ff8c00">Live Demo</font></a>
                                        </div>
                                        <div class="menuLinkHome">
                                            <a href="http://www.sigmawidgets.com/download.html"><font color="ff8c00">Download</font></a>
                                        </div>
                                        <div class="menuLinkHome">
                                            <a href="http://www.sigmawidgets.com/forum"><font color="ff8c00">Forum</font></a>
                                        </div>
                                    </div>
</div>

   
  <div id="header">
  <h1>
      Product - Sigma Grid - Sample&nbsp;</h1>
  </div>

  <div id="content">
    
	  <h2>
          API Samples</h2>
      <p>
          This sample shows how to call Sigma grid API via external button.
         
    </p>
    <div id="bigbox" style="margin:15px;display:!none;">
      <div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:200px;width:700px;" ></div>
    </div>
    <p>
    <input type="button" value="Add New Row" onClick="mygrid.add(['010-0','US','Jerry','Keith',0,0,0,0,'2008-10-02'])">
    <input type="button" value="Remove Selected Row" onClick="mygrid.del()">
    <input type="button" value="Save Changes" onClick="mygrid.save()">
    <input type="button" value="Refresh" onClick="mygrid.reload()">
    <input type="button" value="Print Grid" onClick="mygrid.print()">
    <input type="button" value="Export To Excel" onClick="mygrid.exportGrid('xls')">
    <input type="button" value="Export To XML" onClick="mygrid.exportGrid('xml')">
    <input type="button" value="Export To CSV" onClick="mygrid.exportGrid('csv')">
    <input type="button" value="Export To PDF" onClick="mygrid.exportGrid('pdf')">
    <input type="button" value="Show Filter Box" onClick="mygrid.showDialog('filter')">
    <input type="button" value="Show Chart Box" onClick="mygrid.showDialog('chart')"></p>
    <p>
    <input id="bbb" type="button" value="RUN TEST CASE" onClick="testIt();">
    </p>
    
      <h2>Related Links </h2>
      <p><a href="example_row_conditional_formatting.html">User defined cell renderer</a> - <a href="example_cell_link.html"> Hyper link cell</a>&nbsp;- <a href="example_cell_long_text.html">Long text in cell</a> &nbsp;</p>
  </div>
  
  
 <h1 id="qunit-header">QUnit Test Suite</h1>  
 <h2 id="qunit-banner"></h2>  
 <div id="qunit-testrunner-toolbar"></div>  
 <h2 id="qunit-userAgent"></h2>  
 <ol id="qunit-tests"></ol>  

  <div id="footer">All contents are (c) Copyright 2005 - 2008, Sigma Software Inc. All rights Reserved</div>
</div>

</body>
</html>